﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using DG.Tweening;

public class UIGuideHint : UIObject
{
    public Transform title1;
    public Transform title2;
    public Transform title3;
    public GameObject guideRoot;
    // Start is called before the first frame update
    protected override void onVisible()
    {
        base.onVisible();
        Open();
    }

    Sequence _sequence;
    protected override void OnInvisible()
    {
        base.OnInvisible();
        _sequence.Kill();
    }


    private void Open()
    {
        title1.localPosition = new Vector3(0, -500, 0);
        title2.localPosition = new Vector3(0, -500, 0);
        title3.localPosition = new Vector3(0, -500, 0);

        Sequence s = DOTween.Sequence(this.gameObject);
        s.AppendInterval(16f);
        s.Append(title1.DOLocalMoveY(148 + 10, 1));
        s.Append(title1.DOLocalMoveY(148, 0.1f));
        s.Append(title2.DOLocalMoveY(83 + 10, 1));
        s.Append(title2.DOLocalMoveY(83, 0.1f));
        s.AppendInterval(1);
        s.Append(title3.DOLocalMoveY(18 + 10, 1));
        s.Append(title3.DOLocalMoveY(18, 0.1f));
        s.AppendInterval(2);

        s.AppendCallback(OnAniFinish);
        //设置次数
        //s.SetLoops(4, LoopType.Yoyo);
        _sequence = s;
    }

    private void OnAniFinish()
    {
        guideRoot.SetActive(false);
        guideRoot.SetActive(true);
        Debug.Log("动画重新播放");
    }
}
